<template>
  <div>
    <div class="header">111</div>
    <el-card class="box">
      <!-- 新增试题按钮 -->
      <el-row class="tianjia-shiti">
        <el-button type="success" size="medium  ">
          <i class="el-icon-edit"></i>
          新增试题
        </el-button>
      </el-row>
      <!-- 新增试题按钮 -->
      <!-- 搜索区域 -->
      <el-form>
        <el-row>
          <el-col :span="6">
            <el-form-item label="学科">
              <el-select
                v-model="basicId"
                placeholder="请选择"
                @change="geterji($event)"
              >
                <el-option
                  :key="item.value"
                  v-for="item in shuju"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="二级目录">
              <el-select v-model="select" placeholder="请选择">
                <el-option
                  :key="item.value"
                  v-for="item in erjishuju"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="标签">
              <el-select v-model="sanjiId" placeholder="请选择">
                <el-option
                  :label="item.label"
                  :value="item.value"
                  :key="item.value"
                  v-for="item in threeshuju"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="关键字">
              <el-input v-model="guanjianz"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="试题类型">
              <el-select v-model="testType" placeholder="请选择">
                <el-option label="单选" value="1"></el-option>
                <el-option label="双选" value="2"></el-option>
                <el-option label="多选" value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="难度">
              <el-select v-model="testDifficulty" placeholder="请选择">
                <el-option label="简单" value="1"></el-option>
                <el-option label="一般" value="2"></el-option>
                <el-option label="困难" value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="方向">
              <el-select v-model="direction" placeholder="请选择">
                <el-option label="o2o" value="o2o"></el-option>
                <el-option label="外包服务" value="waibao"></el-option>
                <el-option label="企业服务" value="qiyefuwu"></el-option>
                <el-option label="互联网服务" value="hunianfuwu"></el-option>
                <el-option label="企业咨询" value="qiyezhixun"></el-option>
                <el-option label="互联网" value="hunianwang"></el-option>
                <el-option label="电子商务" value="dianzshangwu"></el-option>
                <el-option label="其他" value="qita"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="录入人">
              <el-select v-model="lururen" placeholder="请选择">
                <el-option
                  :label="item.username"
                  value="lururen"
                  :key="item.id"
                  v-for="item in luruRen"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="题目备注">
              <el-input v-model="timubeizhu"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="企业简称">
              <el-input v-model="qiyejiancheng"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="城市">
              <el-col :span="12">
                <el-select v-model="formInline.user" placeholder="请选择">
                  <el-option label="区域一" value="shanghai1"></el-option>
                  <el-option label="区域二" value="beijing1"></el-option>
                </el-select>
              </el-col>
              <el-col :span="12">
                <el-select v-model="formInline.user" placeholder="请选择">
                  <el-option label="区域一" value="shanghai1"></el-option>
                  <el-option label="区域二" value="beijing1"></el-option>
                </el-select>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <div class="kaoyou">
              <el-button size="mini">清除</el-button>
              <el-button type="primary" size="mini">搜索</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
      <el-row class="el-alert ">
        <i class="el-icon-info"></i>
        <span>数据一共有七条</span>
      </el-row>
      <!-- 搜索区域 -->
      <!-- 显示区域 -->
      <el-table :data="contentData" style="width: 100%">
        <el-table-column
          prop="addDate"
          label="试题编号"
          min-width="220"
        ></el-table-column>
        <el-table-column
          prop="subject"
          label="学科"
          min-width="90"
        ></el-table-column>
        <el-table-column prop="catalog" label="目录" min-width="90">
        </el-table-column>
        <el-table-column prop="questionType" label="题型" min-width="90">
          <template slot-scope="scope">
            <span v-if="scope.row.questionType == 1">单选</span>
            <span v-else-if="scope.row.questionType == 2">双选</span>
            <span v-else>简单</span>
          </template>
        </el-table-column>
        <el-table-column prop="question" label="题干" min-width="280">
          <template slot-scope="scope">
            <span v-html="scope.row.question"></span>
          </template>
        </el-table-column>
        <el-table-column prop="addDate" label="录入时间" width="180">
          <template slot-scope="scope">
            <span>{{ scope.row.addDate | relativeTime }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="difficulty" label="难度" width="92">
          <template slot-scope="scope">
            <span v-if="scope.row.difficulty == 1">简单</span>
            <span v-else-if="scope.row.difficulty == 2">一般</span>
            <span v-else>困难</span>
          </template>
        </el-table-column>
        <el-table-column prop="creator" label="录入人" width="92">
        </el-table-column>
        <el-table-column prop="address" label="操作" width="200">
          <el-button
            type="primary"
            icon="el-icon-view"
            plain
            circle
            @click="topicPreview()"
          ></el-button>
          <el-button
            type="success"
            icon="el-icon-edit"
            plain
            circle
          ></el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            plain
            circle
            @click="deleteTitle()"
          ></el-button>
          <el-button
            type="warning"
            icon="el-icon-check"
            plain
            circle
          ></el-button>
        </el-table-column>
      </el-table>
      <!-- 显示区域 -->
      <!-- 分页区 -->
      <!-- <el-pagination background :page-size="[5, 10, 20, 50]" :total="20"> </el-pagination> -->
      <div class="block">
        <el-pagination
          :page-sizes="[5, 10, 15, 20]"
          :page-size="3"
          layout="total, sizes, prev, pager, next, jumper"
          :total="20"
          background
        ></el-pagination>
      </div>
      <!-- 分页区 -->
      <!-- 题目预览 -->
      <el-dialog title="题目预览" :visible.sync="topicPreviewShow" radius>
        <el-row>
          <el-col :span="6">【题型】：多选题</el-col>
          <el-col :span="6">【编号】：30</el-col>
          <el-col :span="6">【难度】：困难</el-col>
          <el-col :span="6">【标签】：hadoop</el-col>
          <el-col :span="6">【学科】：大数据</el-col>
          <el-col :span="6">【目录】：数据存储</el-col>
          <el-col :span="6">【方向】：o2o</el-col>
          <el-col :span="24"><hr /></el-col>
          <el-col :span="24">【题干】：</el-col>
          <el-col :span="24">1111</el-col>
          <el-col :span="24">多选题 选项：（以下选中的选项为正确答案）</el-col>
          <el-col :span="24"><el-radio></el-radio>1</el-col>
          <el-col :span="24"><el-radio></el-radio>1</el-col>
          <el-col :span="24"><el-radio></el-radio>1</el-col>
          <el-col :span="24"><hr /></el-col>
          <el-col :span="24"
            >【参考答案】：
            <el-button type="danger">视频答案预览</el-button></el-col
          >
          <el-col :span="24"><hr /></el-col>
          <el-col :span="24">【答案解析】：无</el-col>
          <el-col :span="24"><hr /></el-col>
          <el-col :span="24">【题目备注】：无</el-col>
        </el-row>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="topicPreviewShow = false"
            >关闭</el-button
          >
        </span>
      </el-dialog>
      <!-- 题目预览 -->
      <!-- 题目删除操作 -->
      <el-dialog title="提示" :visible.sync="deleteTitleShow" width="20%">
        <span
          ><i class="el-icon-warning-outline"></i
          ><i class="wenzhi">此操作将永久删除改题目，是否继续？</i></span
        >
        <span slot="footer" class="dialog-footer">
          <el-button @click="deleteTitleShow = false">取 消</el-button>
          <el-button type="primary" @click="deleteTitleShow = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
      <!-- 题目删除操作 -->
      <!-- 加入精选操作 -->
      <el-dialog title="提示" :visible.sync="deleteTitleShow" width="20%">
        <span
          ><i class="el-icon-warning-outline"></i
          ><i class="wenzhi">此操作将永久删除改题目，是否继续？</i></span
        >
        <span slot="footer" class="dialog-footer">
          <el-button @click="deleteTitleShow = false">取 消</el-button>
          <el-button type="primary" @click="deleteTitleShow = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
      <!-- 加入精选操作 -->
    </el-card>
  </div>
</template>

<script>
import {
  BasicBank,
  BasicBankTwo,
  BasicBankThree,
  lururen,
  BasicBankFour
} from '@/api/tk-huoqu'
export default {
  name: 'basic_question-bank',
  data() {
    return {
      guanjianz: '',
      timubeizhu: '',
      qiyejiancheng: '',
      formInline: {
        user: '',
        region: ''
      },
      shuju: [], // 基础数据集合
      erjishuju: [],
      select: '',
      threeshuju: [],
      luruRen: [],
      contentData: [],
      data: {
        page: 1,
        pagesize: 5
      },
      basicId: [],
      erjiId: [],
      sanjiId: '',
      testType: [],
      testDifficulty: [],
      direction: [],
      lururen: [],
      topicPreviewShow: false, // 控制题目组件显示隐藏
      deleteTitleShow: false
    }
  },
  created() {
    this.getBasicBank()
  },
  methods: {
    // 获取基础题库数据
    async getBasicBank() {
      try {
        const { data } = await BasicBank(this.data)
        // console.log(data, 1111)
        this.shuju = data
        console.log(this.shuju, '基础题库数据')
        const { data: luruRen } = await lururen()
        this.luruRen = luruRen // 获取录入人
        console.log(luruRen, '录入人')
        const { data: contentData } = await BasicBankFour()
        this.contentData = contentData.items
        console.log(this.contentData, '试题内容数据')
      } catch {
        console.log('错误')
      }
    },
    geterji(event) {
      this.erjiId = []
      // console.log(event, 5555)
      const id = event
      this.erjiId.push(id)
      console.log(this.erjiId, '学科ID')
      this.getBasicBankTwo({ subjectID: this.erjiId[0] })
      this.getBasicBankThree({ subjectID: this.erjiId[0] })
    },
    async getBasicBankTwo(id) {
      try {
        const { data: res } = await BasicBankTwo(id)
        this.erjishuju = res
        console.log(this.erjishuju, '二级目录数据')
      } catch {
        console.log('错误')
      }
    },
    async getBasicBankThree(id) {
      try {
        const { data: res } = await BasicBankThree(id)
        this.threeshuju = res
        console.log(this.threeshuju, '标签数据')
      } catch {
        console.log('错误')
      }
    },
    // 题目预览
    topicPreview() {
      this.topicPreviewShow = true
    },
    // 删除题目操作
    deleteTitle() {
      this.deleteTitleShow = true
    }
  }
}
</script>

<style lang="less" scoped>
.header {
  height: 34px;
  width: 100%;
  background-color: #fff;
}
.box {
  margin: 20px;
  .tianjia-shiti {
    margin-bottom: 15px;
  }
}
/deep/.el-form-item__content {
  display: flex;
  flex: 1;
  flex-direction: row-reverse;
}
/deep/.el-input--suffix {
  width: 100%;
}
/deep/.el-form-item__label {
  width: 80px;
  text-align: right;
  vertical-align: middle;
  float: left;
  font-size: 14px;
  color: #606266;
  line-height: 40px;
  padding: 0 12px 0 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.tianjia-shiti {
  display: flex;
  justify-content: flex-end;
}
.el-select {
  width: 100%;
}
.kaoyou {
  display: flex;
  justify-content: flex-end;
}
.el-alert {
  background-color: #f4f4f5;
  color: #909399;
  .el-icon-info:before {
    margin-right: 10px;
  }
}
/deep/.is-circle {
  font-size: 11px;
}
.el-pagination {
  float: right;
}
/deep/.el-dialog {
  width: 900px;
  border-radius: 10px;
  .el-col {
    padding: 10px 0 10px;
  }
}
/deep/.el-dialog__header {
  background: #409eff;
  border-radius: 10px 10px 0 0;
}
// /deep/.data-v-59a9ccae {
//   font-size: 50px;
// }
/deep/.el-icon-warning-outline {
  color: #e6a23c;
  font-size: 20px;
}
.wenzhi {
  font-size: 20px;
}
</style>
